<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <ul>
    <li class="woman">小红</li>
    <li class="man">小明</li>
    <li class="man">小强</li>
    <li class="woman">小兰</li>
  </ul>
</body>

</html>
<script>
  //根据类名woman获取元素
  var women = document.getElementsByClassName('woman')
  //根据类名id获取元素
  var men = document.getElementsByClassName('man')
  //输出类名woman的第1个元素
  console.log(women[0]);
  //输出类名man的第1个元素
  console.log(men[0]);
</script>